package com.codelab.statemachine.service;

import cn.hutool.core.util.RandomUtil;
import com.codelab.statemachine.task.ExecutePOJO;
import com.codelab.statemachine.task.TaskExecute;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class Demo1Executor implements TaskExecute {
    @Override
    public String getTaskCode() {
        return "demo1";
    }

    @Override
    public ExecutePOJO execute(Map map) {
        System.out.println("===================Demo1 execute=================");
        try {
            Thread.sleep(RandomUtil.randomLong(1000,5000));
        } catch (InterruptedException e) {
            //Thread.currentThread().interrupted();
            throw new RuntimeException(e);
        }
        return new ExecutePOJO().setCode("0");
    }
}
